package com.geuso.xingdutch.util;

import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class SoundUtil {
	
	public static void playSound(Context c, int resource){
		Log.d(SoundUtil.class.getName(), "Attempting to play sound with resource id: " + resource);
		if (resource > 0){
			MediaPlayer mp = MediaPlayer.create(c,  resource);
			mp.start();
		}
		else {
			Log.d(SoundUtil.class.getName(), "Did not play sound with resource: " + resource);
		}
	}
	
	
	public static void setOnClickPlaySound(final ImageView view, final int resource){
		view.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				SoundUtil.playSound(view.getContext(), resource);
				
			}
		});
		
	}
}
